package com.spic.business.mq.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import com.spic.business.hik.constant.HkConstant;
import com.spic.business.mq.domain.FindVehicleByIndexCodeRequest;
import com.spic.common.core.utils.StringUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class HikvehiclealarmUtil
{
    static {
        ArtemisConfig.host = HkConstant.HKVE_HOST;
        ArtemisConfig.appKey = HkConstant.HKVE_AK;
        ArtemisConfig.appSecret = HkConstant.HKVE_SK;
    }


    //根据车辆编号获取车辆信息(含设备)
    public static String findVehicleByIndexCode(FindVehicleByIndexCodeRequest findVehicleByIndexCodeRequest ){
        String findVehicleByIndexCodeDataApi = "/artemis/api/rtsm/v1/resource/findVehicleByIndexCode";
        Map<String,String> path = new HashMap<String,String>(2){
            {
                put("https://",findVehicleByIndexCodeDataApi);
            }
        };
        String body= JSON.toJSONString(findVehicleByIndexCodeRequest);
        String result =ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
        return result;
    }

    /**
     * 调用海康post接口-json
     * @param service api-service
     * @param jsonStr json
     * @return result
     */
    public static String doPostStringArtemis(String service,String jsonStr){
        Map<String, String> path = new HashMap<String, String>(2);
        path.put("https://", service);
        return ArtemisHttpUtil.doPostStringArtemis(path,jsonStr,
                null,null,"application/json",null);
    }
}
